package Game;

import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.input.action.InputActionEvent;
import com.jme.input.action.KeyInputAction;
import com.jme.input.action.KeyNodeForwardAction;
import com.jme.math.Vector3f;
import com.jme.scene.Node;
import com.jme.scene.Spatial;
import javax.swing.JProgressBar;

public class KeyNodeRunAction extends KeyInputAction{
    
    private static final Vector3f tempVa = new Vector3f();

    private Spatial player;

    public KeyNodeRunAction(Node player, float runSpeed){
        this.player = player;
        this.speed = runSpeed;
    }

    public void performAction(InputActionEvent evt) {
        if(CustomFPSInputHandler.getCondition() != 0){
            Vector3f loc = player.getLocalTranslation();
            loc.addLocal(player.getLocalRotation().getRotationColumn(2, tempVa)
                    .multLocal(speed * evt.getTime()));
            player.setLocalTranslation(loc);
            CustomFPSInputHandler.setCondition(CustomFPSInputHandler.getCondition()-1);
        }
    }
}
